define(['../../../../../js/lib/other/sweet-alert'],function() {
    return ['$scope','$location', '$interval','$timeout','bizProxy', function($scope,$location,$interval,$timeout,bizProxy) {
    	$scope.$emit("top-show",'true');//显示顶部
    	$scope.$emit('menuTypeLight','mine'); 	//控制底部menu高亮
    	$scope.$emit('bub-menu','true'); 	//隐藏底部menu
    	$scope.$emit('flag-tag','65'); 	//显示底部文字
    	
    	//if(! _MZ_isWEIXIN.isWeiXin()){
	   		 $scope.loginPassword = true;
		//}else{
		//	$scope.loginPassword = false;
		//}
		//
		if(_YHC_isWEIXIN.isWeiXin()){
	   		 $scope.ifshowlogout = false;
		}else{
			$scope.ifshowlogout = true;
		}
    	
    	
    	//默认
    	$scope.isSlider = false;
    	$scope.isSliderPwd = false;
    	var imageProdUrl = "";
    	var tempName = resultData.loginResultData.nickName;
		if(tempName.substring(0,3) == 'YHC' && !(isNaN(tempName.substring(3,11)*1))){
			$scope.isShow = true;
		}else{
			$scope.isShow = false;
		}
		$scope.userName = resultData.loginResultData.nickName;
    	
    	$scope.mobileNo = resultData.loginResultData.mobileNo;
    	$scope.loginPwdName = (resultData.loginResultData.hasLoginPwd == "Y")?"修改":"未设置";
    	$scope.payPwdName = (resultData.loginResultData.hasPayPwd == "Y")?"修改":"未设置";
    	

    	//点击更改用户名
    	$scope.changeName = function(){
    		var name = resultData.loginResultData.nickName;
    		if(name.substring(0,3) == 'YHC' && !(isNaN(name.substring(3,11)*1))){
    			$scope.$emit('goNext','/changeName');
    		}
    	}
    	
    	//点击更改手机号
    	$scope.changeMobileNo = function(){
    		$scope.$emit('goNext','/changeNo');
    	}
    	
    	//点击设置登录密码
    	$scope.setLoginPwd = function(){
    		if(resultData.loginResultData.hasLoginPwd == "Y"){
    			$scope.isSliderPwd = true;
    		}else{
    			$scope.$emit('goNext','/setLoginPwd');
    		}
    	}
    	
    	//点击通过旧密码方式
    	$scope.editOldPwd = function(){
    		$scope.isSliderPwd = false;
    		$timeout(function(){
    			$scope.$emit('goNext','/changePwdByOldPwd');
    		},100);
    		
    	}
        //点击个人信息
        $scope.goPersonalInfo = function(){
            if(resultData.loginUserData != "" && resultData.loginUserData != null){
                if(resultData.loginUserData.idNo != "" && resultData.loginUserData.idNo != null){
                    $timeout(function(){
                        $scope.$emit("goNext","/personalInfo");
                    },300);
                }else{
                    $timeout(function(){
                        // $scope.$emit("goNext","/completePtData");
                        $scope.$emit("goNext","/completeData");
                    },300);
                }
            }else{
                $timeout(function(){
                    // $scope.$emit("goNext","/completePtData");
                    $scope.$emit("goNext","/completeData");
                },300);
            }
        }
    	//点击通过手机验证方式
    	$scope.editPhoneAuth = function(){
    		$scope.isSliderPwd = false;
    		
    		var tempTime = 200;
    		if(_YTG_IOSorANDROID.systemJudge() == 'IOS'){
    			tempTime = 1000;
    		}
    		
    		$timeout(function(){
    			$scope.$emit('goNext','/changePwdByMobile');
    		},tempTime);
    		
    	}

    	//点击退出登录
    	$scope.logout = function(){
    		var sweetData = {
  					title : "是否确定要退出登录？",
  					text : "",
  					type : "",
  					showCancelButton : true,
  					closeOnConfirm : false
  				};
      			sweetAlert(sweetData,function(){
      				$timeout(function(){
      					layout();
      				},0);
      			},function(){return;});
    	}
    	
    	//退出登录
    	function layout(){
    		var headerInfo = {},bizInfo = {};
	       	headerInfo.pageNum = '';
	       	headerInfo.pageSize = '';
	       	headerInfo.sessionId =transData.sessionId;
	       	$scope.$emit("loadingChange",true);
	       	bizProxy.queryProxyBizData("userLogout", headerInfo,bizInfo,
	   				function(tempData){
	   					$scope.$emit("loadingChange",false);
	   					if(tempData.isSuccess == 'T'){
	   		    				$scope.$emit("showCollect",false);
	   		    				//清空相关数据
	   							transData.loginResult = "";
	   							transData.sessionId = "";
	   							localStorage.setItem("fireFlySessionId","");
	   							mchLoginResult = "";
	   							localStorage.clear();
	   							
	   							$location.path("/changeName").replace();//想改变当前 URL 而不创建新的历史记录的话
            					$scope.$emit('goNext','/mine');
	   					}
	   				},
	   				function(data){
	   					$scope.$emit("loadingChange",false);
                        $scope.$emit("promptAlertMsg",data.errorMsg);
                        $scope.$emit("showCollect",true);
                        $timeout(function(){
                            $scope.$emit("showCollect",false);
                        },transData.promptTime);
	   				});
    	}
    	

		$scope.canclePwd = function(){
			$scope.isSliderPwd = false;
		}

        
    	$scope.$apply();
    }];
});